//
// Created by 先通明 on 2018/8/17.
//

#include <stdio.h>
#include "pe12-2a.h"


static int mode;//模式
static double distance;//距离
static double fuel;//燃料

void set_mode(int mod) {
    if (mod > -1 && mod < 2) {
        mode = mod;
    } else{
        puts("Invalid mode specified. Mode 1( US) used.");
        mode = 1;
    }
}

void get_info() {
    if (mode==1){
        printf("Enter distance traveled in miles:");
        scanf("%lf", &distance);
        printf("Enter fuel consumed in gallons:");
        scanf("%lf", &fuel);
    } else{
        printf("Enter distance traveled in kilometers:");
        scanf("%lf", &distance);
        printf("Enter fuel consumed in liters:");
        scanf("%lf", &fuel);
    }
}
void show_info() {
    if (mode==1){
        printf("Fuel consumption is %.2f liters per 100 km.", fuel / distance * 100);
    } else{
        printf("Fuel consumption is %.2f mile per gallon.",  distance / fuel);
    }
}